<template>
  <div class="page-step">
    <div v-for="(item, index) in data" :key="index" class="page-step-item mt-12">
      <div class="page-step-itemtitle gray-color000 mb-8">
        <span>第{{ getItem[index + 1] }}次邀约, </span>
        <span class="ml-8">{{ item.notification_type == 'sms' ? '短信通知' : item.notification_type == 'share' ? '链接分享':'邮件通知' }}</span>
      </div>
      <el-steps direction="vertical" :active="3" size="small" finish-status="finish" style="padding: 0px">
        <el-step>
          <template #icon>
            <div class="ml-8">
              <el-radio v-model="radio" :label="1"><span></span></el-radio>
            </div>
          </template>
          <template #title>
            <span class="f-12 gray-color000">创建时间</span>
          </template>
          <template #description>
            <div class="gray-color pb-8">{{getTime(item.created_at, 'time')}}</div>
          </template>
        </el-step>
        <el-step title="Step 2">
          <template #icon>
            <div class="ml-8">
              <el-radio v-model="radio" :label="1"><span></span></el-radio>
            </div>
          </template>
          <template #title>
            <div class="f-12" v-if="item.state!=null">
              <div v-if="item.state == 5">
                <span class="gray-color000">报告生成失败</span>
                <span class="base-color ml-8 pointer" @click="handlerResetItem(item)">点击重新生成</span>
              </div>
              <div v-if="item.state == 6">
                <span class="pointer basegColor bold" @click="handlerItem(item)">查看报告</span>
              </div>
              <div class="gray-color000" v-if="item.state != 5 && item.state != 6">
                {{status[item.state]}}
              </div>
            </div>
            <div class="f-12 gray-color000" v-else>发送中...</div>
          </template>
          <template #description>
            <div class="gray-color pb-8">{{getTime(item.changed_at, 'time')}}</div>
          </template> 
        </el-step>
        <el-step title="Step 3">
          <template #icon>
            <div class="ml-8">
              <el-radio v-model="radio" :label="1"><span></span></el-radio>
            </div>
          </template>
          <template #title>
            <span class="f-12 gray-color000">截至日期</span>
          </template>
          <template #description>
            <div class="gray-color pb-8">{{getTime(item.deadline, 'time')}}</div>
          </template> 
        </el-step>
      </el-steps>
    </div>
  </div>
</template>

<script setup>
import { ref, defineProps, defineEmits } from 'vue'
import { getTime } from '@/utils/utils'
import { Toast } from '@/utils/vant'
import { useRoute, useRouter } from 'vue-router'
import { generateReport }  from '@/api/api'
const emit = defineEmits(['reset'])
const router = useRouter()
defineProps({
  data:{
    type:Array,
    default: () => []
  }
})
const radio = ref(1)
const status =  ref({
  "-1": '发送成功',
  "-2": '发送失败',
  0: '拒绝面试',
  1: '接受面试',
  2: '面试中',
  3: '完成面试',
  4: '报告生成中',
  5: '报告生成失败',
  6: '查看报告'
})

const getItem = ref({
  1: '一',
  2: '二',
  3: '三',
  4: '四',
  5: '五',
  6: '六',
  7: '七',
  8: '八',
  9: '九',
  10: '十'
})


const handlerItem = (e) => {
  window.open(`/candidates/report/${e.interview_id}`, '_blank')
  // router.push({
  //   path: `/candidates/report/${e.interview_id}`
  // })
}

const handlerResetItem = (e) => {
  generateReport({
    interview_id: e.interview_id
  }).then(res => {
    Toast('重新生成成功')
    emit('reset', e)
  })
}

</script>

<style lang="scss" scoped>
::v-deep .el-popper{
  padding: 0px!important
}

::v-deep .el-step__icon{
  height: 16px;
}

::v-deep .el-popover.el-popper{
  padding: 0px!important
}

.step-icon{
  width:10px;
  height:10px;
  // border:#000 1px solid;
  border-radius: 10px
}

::v-deep .el-step.is-vertical .el-step__title{
  padding-bottom: 4px;
  line-height: 16px;
}

::v-deep .el-step__line{
  border: none;
  background:none;
  border-color:#ddd;
  color:#ddd
}
.page-step{
  max-height: 300px;
  overflow-y: auto;
  padding: 0 16px;
}
</style>